package com.xy.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/17 20:38
 * @description
 */
public class InfoCollegeIterator implements Iterator<Department> {
    // 以List存放
    private List<Department> departments;
    int index = -1;

    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (index >= departments.size() - 1) {
            return false;
        }
        return true;
    }

    @Override
    public Department next() {
        index++;
        return departments.get(index);
    }
}
